home *** CD-ROM | disk | FTP | other *** search
/ Crosscountry USA Photo Safari / Crosscountry USA Photo Safari.iso / Data / cc_base / pak00_16bit_f.pk3 / fuel.tab.p < prev    next >
Text File  |  2003-01-03  |  20KB  |  543 lines

  1. {
  2.   X = 601;
  3.   Y = 65;
  4.   state = 0;
  5.   rest_x = 601;
  6.   expand_x = 400;  
  7.   Hidden = 1;
  8.  
  9.   ChildID = {
  10.  
  11.     GuiAnimation("plate") {
  12.       AnimationID = "gui/dash/tab/plate/plate.pcx";
  13.       X = 39;
  14.       Width = 240;
  15.       Height = 180;
  16.     },
  17.     GuiAnimation("tab") {
  18.       Y = 46;
  19.       AnimationID = "gui/dash/tab/fuel/fuel_off.pcx";
  20.       ScriptID = script {
  21.         @activate {
  22.           resid Parent;
  23.           resid Player;
  24.           resid Game;
  25.           Game = ResByName("Game");
  26.           Player = ResPropGetResID(ResByName("Game"),"game_cur_player");          
  27.           Parent = GuiParent(SELF);
  28.  
  29.           if ( ResPropGetResID(Player,"truck_tab_expanded") == Parent) {
  30.             ResPropSetResID(Player,"truck_tab_expanded",RES_INVALID);
  31.           } else {
  32.             ResPropSetResID(Player,"truck_tab_expanded",Parent);
  33.             GuiToFront(Parent);
  34.             /*
  35.                if we can get fuel here then hit the brakes
  36.                so the user has a chance to make a choice
  37.             */
  38.             
  39.             if ( ResPropGetInt(Player,"nav_can_fuel") == 1) {
  40.               if ( ResPropGetInt(Player,"truck_speed") > 0 ) {
  41.                 ResParseEvent(ResByName("dash.gl/brake_pedal"), "@activate");
  42.               }
  43.             }
  44.           }
  45.  
  46.         }
  47.         @animate {
  48.           resid Parent;
  49.           int state;
  50.           resid Player;
  51.           resid Message;
  52.           resid Game;
  53.           Game = ResByName("Game");
  54.           Player  = ResPropGetResID(ResByName("Game"),"game_cur_player");          
  55.           Message = ResByName("dash.gl/message");
  56.           Parent  = GuiParent(SELF);
  57.  
  58.  
  59.           if ( ResPropGetResID(Player,"truck_tab_expanded") == Parent) {
  60.             ResPropSetInt(Parent,"X",ResPropGetInt(Parent,"expand_x"));
  61.             ResPropSetInt(GuiSiblingByName("plate"),"Hidden",FALSE);
  62.           } else {
  63.           
  64.             ResPropSetInt(GuiSiblingByName("plate"),"Hidden",TRUE);
  65.             ResPropSetInt(Parent,"X",ResPropGetInt(Parent,"rest_x"));
  66.           }
  67.           
  68.           if (ResPropGetInt(Player,"truck_fuel_remaining") <= 0 ) {
  69.             if ( ResPropGetInt(Player,"truck_running") == 1 ) {           
  70.               ResParseEvent(ResByName("dash.gl/brake_pedal"), "@activate");             
  71.               ResParseEvent(ResByName("dash.gl/ignition_switch"), "@activate");
  72.               AudioPlay(ResByName("sound/out_of_gas.wav"));
  73.               ResPropSetStr(
  74.                 Message, 
  75.                 "InputText", 
  76.                 MangleSIDToStr(
  77.                   70/*"OH NO! Your out of fuel, use the cellular phone to call a tow truck."*/
  78.                 )
  79.               );
  80.               ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 10);
  81.             }
  82.           }
  83.           
  84.           /* if we can stop here, highlight me */
  85.           if (ResPropGetInt(Player,"nav_can_fuel") == 0) {
  86.             ResPropSetResID(SELF,"AnimationID",ResByName("gui/dash/tab/fuel/fuel_off.pcx"));
  87.           } else {
  88.             if ( ResPropGetInt(Player,"truck_fuel_remaining") != ResPropGetInt(Game,"game_tank_capacity") ) {
  89.               ResPropSetResID(SELF,"AnimationID",ResByName("gui/dash/tab/fuel/fuel_on.pcx"));
  90.             } else {
  91.               ResPropSetResID(SELF,"AnimationID",ResByName("gui/dash/tab/fuel/fuel_off.pcx"));
  92.             }            
  93.           }
  94.         }
  95.       }
  96.       },
  97.     GuiAnimation("guage") {
  98.       AnimationID = "gui/dash/tab/tab_gauge/tab_gauge.anm";
  99.       State = STOPPED;
  100.       Y = 49;
  101.       X = 5;
  102.       ScriptID = script {
  103.         @animate {
  104.           resid Player;
  105.           resid Game;
  106.           int fuel_remaining;
  107.           int game_tank_capacity;
  108.           int frame_count;
  109.           int frame;
  110.           Game = ResByName("Game");
  111.           Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  112.           frame_count = ResPropGetInt(SELF, "FrameCount");
  113.           ResPropAlias(Player,"truck_fuel_remaining","fuel_remaining");
  114.           ResPropAlias(Game,"game_tank_capacity","game_tank_capacity");
  115.  
  116.           frame = (frame_count * (fuel_remaining / 1000)) / (game_tank_capacity / 1000);
  117.           if ( frame >= frame_count) {
  118.             frame = frame_count - 1;
  119.           }
  120.           if ( frame < 0) {
  121.             frame = 0;
  122.           }
  123.           ResPropSetInt(SELF,"CurrentFrame",frame);
  124.         }
  125.       };
  126.     },
  127.  
  128.    
  129.         GuiTextInput("fuel_message") {
  130.       X = 45;
  131.       Y = 5;
  132.       Width = 185;
  133.       Height = 45;
  134.       TextX = -50;
  135.       WordWrap = TRUE;
  136.       InputDisabled = TRUE;
  137.       FontID = "font/verdana_9.tf";
  138.       ScriptID = Script {
  139.         @animate {
  140.           resid Player;
  141.           resid Game;
  142.           int fuel_capacity;
  143.           str fuel_name;
  144.           int fuel_remaining;
  145.           Game = ResByName("Game");
  146.           Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  147.           fuel_remaining = ResPropGetInt(Player,"truck_fuel_remaining");
  148.           fuel_name = ResPropGetStr(Game,"game_fuel_unit_name");
  149.           fuel_capacity = ResPropGetInt(Game,"game_tank_capacity");
  150.           ResPropSetStr(SELF,"InputText",StrFormatStr(MangleSIDToStr(71/*"You have %d %ss of fuel in your truck. Your tank can hold a total of %d %ss."*/), (fuel_remaining / 1000), fuel_name, (fuel_capacity / 1000), fuel_name));
  151.         }
  152.       };
  153.     },
  154.     GuiAnimation("line") {
  155.       AnimationID = "gui/dash/tab/line/line.pcx";
  156.       Y = 48;
  157.       X = 45;
  158.     },
  159.  
  160.         GuiTextInput("no_gas_message") {
  161.       X = 55;
  162.       Y = 74;
  163.       Width = 180;
  164.       Height = 45;
  165.       WordWrap = TRUE;
  166.       InputDisabled = TRUE;
  167.       FontID = "font/tab_w_on_g.tf";
  168.       ScriptID = Script {
  169.             
  170.         @animate {
  171.           resid Player;
  172.           resid Game;
  173.           Game = ResByName("Game");
  174.           Player = ResPropGetResID(ResByName("Game"),"game_cur_player");  
  175.  
  176.           /* if there is no gas station here or the tank is full set the other things to Hidden */
  177.           if (ResPropGetInt(Player,"nav_can_fuel") == 0) {
  178.             ResPropSetInt(GuiSiblingByName("gas_layer"),"Hidden",TRUE);
  179.             ResPropSetStr(SELF,"InputText",MangleSIDToStr(72/*"There are no gas stations in sight. Try the next city."*/));
  180.  
  181.             if (ResPropGetInt(Player,"truck_fuel_remaining") <= 0 ) {
  182.               ResPropSetStr(SELF,"InputText",MangleSIDToStr(73/*"You are out of fuel. Use your cell phone to call a tow truck."*/));
  183.             }
  184.           } else {         
  185.             ResPropSetStr(SELF,"InputText","");
  186.             ResPropSetInt(GuiSiblingByName("gas_layer"),"Hidden",FALSE);
  187.           }
  188.         }
  189.       };
  190.     },
  191.     
  192.     GuiLayer("gas_layer") {
  193.       X = 60;
  194.       Y = 60;    
  195.       ChildID = {
  196.  
  197.             GuiTextInput("price_label") {
  198.           X = 70;
  199.           Y = -5;
  200.           Width = 180;
  201.           Height = 45;
  202.           WordWrap = TRUE;
  203.           InputDisabled = TRUE;
  204.           FontID = "font/verdana_9.tf";
  205.           ScriptID = Script {
  206.             @loaded {
  207.               resid Game;            
  208.               Game = ResByName("Game");
  209.               ResPropSetStr(SELF,"InputText",StrFormatStr(MangleSIDToStr(74/*"Price per %s:"*/),ResPropGetStr(Game,"game_fuel_unit_name")));
  210.             }
  211.           };
  212.         },
  213.             GuiTextInput("price") {
  214.           X = 100;
  215.           Y = 15;
  216.           Width = 180;
  217.           Height = 45;
  218.           WordWrap = TRUE;
  219.           InputDisabled = TRUE;
  220.           FontID = "font/tab_w_on_g.tf";
  221.           ScriptID = Script {
  222.             @animate {
  223.               resid Player;
  224.               resid Game;
  225.               resid csv_data_id;
  226.               resid city_data_id;
  227.               resid state_data_id;
  228.               str state_name;
  229.               int state_tax;
  230.               int state_row;
  231.               int game_fuel_unit_cost;
  232.               int cost;
  233.               str state_ab;
  234.               Game = ResByName("Game");
  235.               csv_data_id   = ResByName("CSVData");
  236.               city_data_id  = ResPropGetResID(csv_data_id, "city_id");
  237.               state_data_id = ResPropGetResID(csv_data_id, "state_id");
  238.               Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  239.               state_ab = CSVGetStr(city_data_id,"state",CSVSearch(city_data_id,"name",ResPropGetStr(Player,"nav_cur_city")));
  240.               state_row = CSVSearch(state_data_id,"abbreviation",state_ab);
  241.               state_name = CSVGetStr(state_data_id,"name",state_row);
  242.               state_tax  = StrToInt(CSVGetStr(state_data_id,"fuel_tax",state_row));
  243.               game_fuel_unit_cost = ResPropGetInt(Game,"game_fuel_unit_cost");
  244.               
  245.               
  246.               cost = (game_fuel_unit_cost * ( 100 + state_tax )) / 100;
  247.               
  248.               ResPropSetStr(SELF,"InputText",
  249.                               StrFormatStr(
  250.                                 MangleSIDToStr(75/*"$%s"*/),
  251.                                 IntToDecimalStr(cost,100)
  252.                               )
  253.                             );
  254.             }
  255.           };
  256.         },
  257.         GuiButtonGroup("fill_up") {
  258.           X = 0;
  259.           Y = 0;
  260.           RadioGroupID = 1;
  261.           ScriptID = Script {
  262.  
  263.             @activate {
  264.               resid Player;
  265.               resid Game;
  266.               int capacity;
  267.               int remaining;
  268.               int amount_to_fill;
  269.               Game = ResByName("Game");
  270.               Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  271.               capacity = ResPropGetInt(Game,"game_tank_capacity");
  272.               remaining = ResPropGetInt(Player,"truck_fuel_remaining");
  273.               amount_to_fill = capacity - remaining;
  274.               ResPropSetInt(Player,"truck_fuel_to_fill",amount_to_fill);
  275.             }
  276.           };
  277.           ChildID = {
  278.                   GuiButton("fill_up_off") {
  279.                     HorizontalAlign = RIGHTOF;
  280.               HorizontalPadding = 6;
  281.                   StyleID = "gui/bs/radiounsel.gbs";
  282.                   TextID = Mangle(76/*"fill it up"*/);
  283.               FontID = "font/tab_w_on_g.tf";    
  284.                  },          
  285.     
  286.                 GuiButton("fill_up_on") {
  287.                     HorizontalAlign = RIGHTOF;
  288.               HorizontalPadding = 6;            
  289.                   StyleID = "gui/bs/radiosel.gbs";
  290.                   TextID = Mangle(77/*"fill it up"*/);
  291.               FontID = "font/tab_w_on_g.tf";      
  292.                  }        
  293.           };
  294.         },
  295.         
  296.         GuiButtonGroup("34_tank") {
  297.           X = 0;
  298.           Y = 20;
  299.           RadioGroupID = 1;
  300.           ScriptID = Script {
  301.             @activate {
  302.               resid Player;
  303.               resid Game;
  304.               int capacity;
  305.               int remaining;
  306.               int amount_to_fill;
  307.               Game = ResByName("Game");
  308.               Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  309.               capacity = ResPropGetInt(Game,"game_tank_capacity");
  310.               remaining = ResPropGetInt(Player,"truck_fuel_remaining");
  311.               
  312.               amount_to_fill = (capacity * 3) / 4;
  313.               if ((amount_to_fill + remaining) > capacity) {
  314.                amount_to_fill = capacity - remaining;
  315.               }
  316.               
  317.               ResPropSetInt(Player,"truck_fuel_to_fill",amount_to_fill);
  318.             }
  319.           };
  320.           ChildID = {
  321.                   GuiButton("34_up_off") {
  322.                     HorizontalAlign = RIGHTOF;
  323.               HorizontalPadding = 6;
  324.                   StyleID = "gui/bs/radiounsel.gbs";
  325.                   TextID = Mangle(78/*"3/4 tank"*/);
  326.               FontID = "font/tab_w_on_g.tf";    
  327.                  },          
  328.     
  329.                 GuiButton("34_up_on") {
  330.                     HorizontalAlign = RIGHTOF;
  331.               HorizontalPadding = 6;            
  332.                   StyleID = "gui/bs/radiosel.gbs";
  333.                   TextID = Mangle(79/*"3/4 tank"*/);
  334.               FontID = "font/tab_w_on_g.tf";      
  335.                  }        
  336.           };
  337.         },
  338.         
  339.         GuiButtonGroup("12_tank") {
  340.           X = 0;
  341.           Y = 40;
  342.           RadioGroupID = 1;
  343.           ScriptID = Script {
  344.             @activate {
  345.               resid Player;
  346.               resid Game;
  347.               int capacity;
  348.               int remaining;
  349.               int amount_to_fill;
  350.               Game = ResByName("Game");
  351.               Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  352.               capacity = ResPropGetInt(Game,"game_tank_capacity");
  353.               remaining = ResPropGetInt(Player,"truck_fuel_remaining");
  354.               
  355.               amount_to_fill = (capacity * 2) / 4;
  356.               if ((amount_to_fill + remaining) > capacity) {
  357.                 amount_to_fill = capacity - remaining;
  358.               }
  359.               
  360.               ResPropSetInt(Player,"truck_fuel_to_fill",amount_to_fill);
  361.             }
  362.           };
  363.           ChildID = {
  364.                   GuiButton("12_up_off") {
  365.                     HorizontalAlign = RIGHTOF;
  366.               HorizontalPadding = 6;
  367.                   StyleID = "gui/bs/radiounsel.gbs";
  368.                   TextID = Mangle(80/*"1/2 tank"*/);
  369.               FontID = "font/tab_w_on_g.tf";    
  370.                  },          
  371.     
  372.                 GuiButton("12_up_on") {
  373.                     HorizontalAlign = RIGHTOF;
  374.               HorizontalPadding = 6;            
  375.                   StyleID = "gui/bs/radiosel.gbs";
  376.                   TextID = Mangle(81/*"1/2 tank"*/);
  377.               FontID = "font/tab_w_on_g.tf";      
  378.                  }        
  379.           };
  380.         },
  381.         
  382.         GuiButtonGroup("14_tank") {
  383.           X = 0;
  384.           Y = 60;
  385.           RadioGroupID = 1;
  386.           ScriptID = Script {
  387.             @activate {
  388.               resid Player;
  389.               resid Game;
  390.               int capacity;
  391.               int remaining;
  392.               int amount_to_fill;
  393.               Game = ResByName("Game");
  394.               Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  395.               capacity = ResPropGetInt(Game,"game_tank_capacity");
  396.               remaining = ResPropGetInt(Player,"truck_fuel_remaining");
  397.               
  398.               amount_to_fill = capacity / 4;
  399.               if ((amount_to_fill + remaining) > capacity) {
  400.                 amount_to_fill = capacity - remaining;
  401.               }
  402.               ResPropSetInt(Player,"truck_fuel_to_fill",amount_to_fill);
  403.             }
  404.           };
  405.           ChildID = {
  406.                   GuiButton("14_up_off") {
  407.                     HorizontalAlign = RIGHTOF;
  408.               HorizontalPadding = 6;
  409.                   StyleID = "gui/bs/radiounsel.gbs";
  410.                   TextID = Mangle(82/*"1/4 tank"*/);
  411.               FontID = "font/tab_w_on_g.tf";    
  412.                  },          
  413.     
  414.                 GuiButton("14_up_on") {
  415.                     HorizontalAlign = RIGHTOF;
  416.               HorizontalPadding = 6;
  417.                   StyleID = "gui/bs/radiosel.gbs";
  418.                   TextID = Mangle(83/*"1/4 tank"*/);
  419.               FontID = "font/tab_w_on_g.tf";      
  420.                  }        
  421.           };
  422.         },
  423.         GuiButton("get_gas") {
  424.           X = 80;
  425.           Y = 40;
  426.           TextID = Mangle(84/*"Get Fuel"*/);
  427.           StyleID = "gui/dash/tab/button/tab.gbs";
  428.           FontID = "font/tab_button.tf";
  429.           Width = 80;
  430.           AutoSize = Height;
  431.           ScriptID = Script {
  432.             @activate {
  433.               resid Player;
  434.               resid Game;
  435.               resid csv_data_id;
  436.               resid city_data_id;
  437.               resid state_data_id;
  438.               resid Message;
  439.               resid SelectedFuelAmount;
  440.               int truck_fuel_remaining;
  441.               int truck_fuel_to_fill;
  442.               int game_fuel_unit_cost;
  443.               int expense_spent_on_fuel;
  444.               int bill;              
  445.               str state_name;
  446.               int state_tax;
  447.               int state_row;
  448.               str state_ab;
  449.  
  450.               Game = ResByName("Game");
  451.               Message = ResByName("dash.gl/message");
  452.               Player = ResPropGetResID(ResByName("Game"),"game_cur_player");              
  453.  
  454.               csv_data_id   = ResByName("CSVData");
  455.               city_data_id  = ResPropGetResID(csv_data_id, "city_id");
  456.               state_data_id = ResPropGetResID(csv_data_id, "state_id");
  457.  
  458.               Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  459.               state_ab = CSVGetStr(city_data_id,"state",CSVSearch(city_data_id,"name",ResPropGetStr(Player,"nav_cur_city")));
  460.               state_row = CSVSearch(state_data_id,"abbreviation",state_ab);
  461.               state_tax  = StrToInt(CSVGetStr(state_data_id,"fuel_tax",state_row));
  462.               
  463.               ResPropAlias(Player,"truck_fuel_remaining","truck_fuel_remaining");
  464.               ResPropAlias(Player,"truck_fuel_to_fill","truck_fuel_to_fill");
  465.               ResPropAlias(Game,"game_fuel_unit_cost","game_fuel_unit_cost");
  466.               ResPropAlias(Player,"expense_spent_on_fuel","expense_spent_on_fuel");
  467.               
  468.               SelectedFuelAmount = ResPropGetResID(GuiSiblingByName("fill_up"),"RadioGroupSelectedID");
  469.               ResParseEvent(SelectedFuelAmount,"@activate");
  470.               
  471.               truck_fuel_remaining += truck_fuel_to_fill;
  472.               bill = (((truck_fuel_to_fill / 1000) * game_fuel_unit_cost) * (100 + state_tax));
  473.               bill /= 100;
  474.               
  475.               expense_spent_on_fuel += bill;
  476.                             
  477.               if (bill != 0) {
  478.               
  479.                 ResPropSetStr(Player, "nav_picture", "gas_station");
  480.                 ResPropSetStr(Player, "nav_sound", "gas_station");    
  481.                 if (ResPropGetInt(Player,"nav_at_city") == 0) {
  482.                   ResPropSetInt(Player, "nav_picture_no_dash_flag", 1);
  483.                 }
  484.                 ResPropSetInt(Player, "truck_seatbelt", 0); 
  485.                 ResParseEvent(ResByName("dash.gl/seatbelt"),"@show");  
  486.                 ResPropSetInt(ResByName("dash.gl/full_screen"), "Hidden", FALSE);
  487.                 ResPropSetStr(Message, "InputText", StrFormatStr(MangleSIDToStr(85/*"You spent $%s dollars on %d %ss of fuel."*/), IntToDecimalStr(bill,100), (truck_fuel_to_fill / 1000), ResPropGetStr(Game,"game_fuel_unit_name")));
  488.                 ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 10);
  489.               } else {
  490.                 ResPropSetStr(Message, "InputText", MangleSIDToStr(86/*"Your tank is already full."*/));
  491.                 ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 3);              
  492.               }
  493.  
  494.             }
  495.           };
  496.         }
  497.       };        
  498.     },
  499.     
  500.     
  501.     GuiAnimation("line1") {
  502.       AnimationID = "gui/dash/tab/line/line.pcx";
  503.       Y = 142;
  504.       X = 45;
  505.     },
  506.     
  507.         GuiTextInput("state_tax") {
  508.       X = 45;
  509.       Y = 144;
  510.       Width = 185;
  511.       Height = 35;
  512.       WordWrap = TRUE;
  513.       InputDisabled = TRUE;
  514.       FontID = "font/verdana_9.tf";
  515.       ScriptID = Script {
  516.         @animate {
  517.           resid Player;
  518.           resid Game;
  519.           resid csv_data_id;
  520.           resid city_data_id;
  521.           resid state_data_id;
  522.           str state_name;
  523.           int state_tax;
  524.           int state_row;
  525.           str state_ab;
  526.           Game = ResByName("Game");
  527.  
  528.           csv_data_id = ResByName("CSVData");
  529.           city_data_id = ResPropGetResID(csv_data_id, "city_id");
  530.           state_data_id = ResPropGetResID(csv_data_id, "state_id");
  531.  
  532.           Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  533.           state_ab = CSVGetStr(city_data_id,"state",CSVSearch(city_data_id,"name",ResPropGetStr(Player,"nav_cur_city")));
  534.           state_row = CSVSearch(state_data_id,"abbreviation",state_ab);
  535.           state_name = CSVGetStr(state_data_id,"name",state_row);
  536.           state_tax  = CSVGetInt(state_data_id,"fuel_tax",state_row);
  537.           ResPropSetStr(SELF,"InputText",StrFormatStr(MangleSIDToStr(87/*"%s has a fuel tax of %d percent."*/), state_name, state_tax ));
  538.         }
  539.       };
  540.     }   
  541.   };
  542. }
  543.